using System;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Terra.Data.Entities;

namespace Terra.Data.Entities.Identity
{
    /// <summary>
    /// 角色权限关联实体
    /// </summary>
    [Table("RolePermissions")]
    [Comment("角色权限关联表")]
    [Index(nameof(RoleId), nameof(PermissionId), IsUnique = true, Name = "IX_RolePermission_RolePermission")]
    public class RolePermission : EntityBase<Guid>
    {
        /// <summary>
        /// 角色ID
        /// </summary>
        [Comment("角色ID")]
        public Guid RoleId { get; set; }

        /// <summary>
        /// 权限ID
        /// </summary>
        [Comment("权限ID")]
        public Guid PermissionId { get; set; }

        /// <summary>
        /// 角色
        /// </summary>
        [ForeignKey(nameof(RoleId))]
        public Role Role { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        [ForeignKey(nameof(PermissionId))]
        public Permission Permission { get; set; }
    }
}
